@extends('home.jicheng')
@section('content')
<link type="text/css" rel="stylesheet" href="./public/css/alpha1.css" >
<link type="text/css" rel="stylesheet" href="./public/css/alpha2.css" >
<!--container start-->
<div id="container">
    <div class="w">    
        <div id="content">
            <div id="sub">
<div id="menu">
    <dl class="fore1">
        <dt id="_MYJD_setting">设置</dt>
        <dd class="fore1_1 curr" id="_MYJD_info">
            <a clstag="homepage|keycount|home2013|Homeyser" href="" target="_self">个人信息</a>
        </dd>
        <dd class="fore1_1 curr" id="_MYJD_info">
            <a clstag="homepage|keycount|home2013|Homeyser" href="{{ url('home/user/editpassword') }}" target="_self">修改密码</a>
        </dd>
        <dd class="fore1_1 curr" id="_MYJD_safe">
            <a clstag="homepage|keycount|home2013|Homesafe" href="{{ url('home/user/userorder')}}" target="_self">我的订单</a>
            
        </dd>                      <br><br> 已签到<span class="qdtimes" style="font-size:28px;color:red" >{{$data -> qdtimes}}</span>天<br><input type="submit" class="qd"  value="点击签到" title="签到送10积分哦~" name="qd">
                                    <br><br><br>
                                    你总共有<br><br><span class ="jifen" style="font-size:28px;color:red" >{{$data -> jifen}}</span><br>点积分<br><br>
                                    <input type="submit"  class="choujiang" value="点击抽奖"  name=""><br>
                                    每次消耗88点    
    </dl>
</div>
            </div>
            
            <div id="main">
                <div class="mod-main">
                    <div class="mt">
                        <ul class="extra-l">
                            <li class="fore-1"><a class="curr" href="https://i.jd.com/user/info">基本信息</a></li>   
                        </ul>
                    </div>
                    <form action="{{ url('/home/user/info_edit') }}" method="POST" enctype="multipart/form-data">
                    {{ csrf_field() }}
                    <div class="mc">
                    @if (count($errors) > 0)
                        <div class="alert alert-danger">
                            <ul>
                                @foreach ($errors->all() as $error)
                                    <li>{{ $error }}</li>
                                @endforeach
                            </ul>
                        </div>
                    @endif
                    <input type="hidden" name="id" value="{{ $data -> id }}">
                        <div class="user-set userset-lcol">
                            <div class="form">
                                <div class="item">
                                    <span class="label"><em>*</em>用户名：</span>
                                    <div class="fl">
                                        <input clstag="homepage|keycount|home2013|infoname" type="text" class="itxt" maxlength="20" id="nickName" name="name" value="@if(!empty(old('name'))) {{ old('name') }} @else {{ $data -> name }} @endif">
                                        <div class="clr"></div><div class="prompt-06"><span id="nickName_msg"></span></div>
                                    </div>
                                </div>
                                 <div class="item">
                                    <span class="label"><em>*</em>头像：</span>
                                    <div class="fl">
                                        <input  type="file"  name="pic" >
                                        <div class="clr"></div><div class="prompt-06"><span id="nickName_msg"></span></div>
                                    </div>
                                </div>
                                <div class="item" clstag="pageclick|keycount|201602251|3">
                                    <span class="label"><em>*</em>个性签名：</span>
                                    <div class="fl">
                                        <input clstag="homepage|keycount|home2013|infoname2" type="text" class="itxt"  name="signature" id="realName" value="@if(!empty(old('signature'))) {{ old('signature') }} @else {{ $data -> signature }} @endif">
                                        <div class="clr"></div><div class="prompt-06"><span id="realName_msg"></span></div>
                                    </div>
                                </div>
                                <div class="item" clstag="pageclick|keycount|201602251|3">
                                    <span class="label"><em>*</em>邮箱：</span>
                                    <div class="fl">
                                        <input clstag="homepage|keycount|home2013|infoname2" type="text" class="itxt"  name="email" id="realName" value="@if(!empty(old('name'))) {{ old('email') }} @else {{ $data -> email }} @endif">
                                        <div class="clr"></div><div class="prompt-06"><span id="realName_msg"></span></div>
                                    </div>
                                </div>
                                <div class="item" clstag="pageclick|keycount|201602251|3">
                                    <span class="label"><em>*</em>手机号：</span>
                                    <div class="fl">
                                        <input clstag="homepage|keycount|home2013|infoname2" type="text" class="itxt"  name="phone" id="realName" value="@if(!empty(old('phone'))) {{ old('phone') }} @else {{ $data -> phone }} @endif">
                                        <div class="clr"></div><div class="prompt-06"><span id="realName_msg"></span></div>
                                    </div>
                                </div>
                     
                                <div class="item">
                                    <span class="label">&nbsp;</span>
                                    <div class="fl">
                                        <input type="submit" name='' onclick="return confirm('确认要修改吗?');"value='确认修改'>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div id="user-info" style="width:106px;">
                            <div class="u-pic">
                                <img alt="用户头像" src="{{ asset($data -> pic)}}">
                                <div class="mask"></div>
                                <div class="face-link-box"></div>
                                <a href="" class="face-link">修改头像</a>
                            </div>                         
                        </div>           
                        <div class="clr"></div>
                    </div>
                    </form>
                    
                </div>
            </div>
        </div>
    </div>
</div>
<!--container end-->
    <script type="text/javascript">
         window.onload = function()
            {

                 //配置ajax选项
                $.ajaxSetup({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        }
                });

                $('.qd').on('click',function(){
                    var qd = $(this);
                    // alert(qd);
                    var qdtimes = $('.qdtimes');
                    var jifen = $('.jifen');
                    // alert(jifen.html());
                    //获取原来的值
                    var oldtimes = qdtimes.html();
                    // alert(oldtimes);
                    // var old_value = $(this).next().val();
                    // alert(old_value);
                    //ajax发送
                         $.ajax({
                            //还是跳转到本页面
                            url:"{{ url('/home/user/qd') }}",
                            //get方式
                            type:'GET',

                            //发送新修改的键为id的id值name的new_value
                            data:{oldtimes:oldtimes},

                            //成功执行
                            success:function(data)
                            {
                                // alert(data);
                                var obj = jQuery.parseJSON(data);
                                // alert(obj.shibai);
                                // var newzong = Number(bj.jiacha) + Number(oldzong);

                                if(obj.shibai == '签到失败')
                                {
                                    alert('签到失败');
                                }else if(obj.shibai == '今天您已签到')
                                {
                                    alert('今天您已签到');
                                }else
                                {
                                    qdtimes.html(obj.qdtimes);
                                    jifen.html(obj.jifen);
                                }
                            },

                            //失败执行
                            error:function()
                            {
                                alert(222);
                            },

                            //返回类型
                            dataType:'text'

                         });

                    isdb = true;
                });

                $('.choujiang').on('click',function(){
                    var cj = $(this);
                    // alert(cj);
                    var jifen = $('.jifen');
                    // alert(jifen.html());
                    //获取原来的值

                    // alert(oldtimes);;
                    //ajax发送
                         $.ajax({
                            //还是跳转到本页面
                            url:"{{ url('/home/user/cj') }}",
                            //get方式
                            type:'GET',

                            // //发送新修改的键为id的id值name的new_value
                            // data:{oldtimes:oldtimes},

                            //成功执行
                            success:function(data)
                            {
                                // alert(data);
                                var obj = jQuery.parseJSON(data);
                                // alert(obj.shibai);
                                // var newzong = Number(bj.jiacha) + Number(oldzong);

                                if(obj.shibai == '您的积分不足')
                                {
                                    alert('您的积分不足');
                                }else
                                {
                                    jifen.html(obj.jifen);
                                    alert(obj.jiangpin);
                                }
                            },

                            //失败执行
                            error:function()
                            {
                                alert('ajax失败');
                            },

                            //返回类型
                            dataType:'text'

                         });

                    isdb = true;
                });
            }
    </script>

@endsection('content')